﻿/*-----------------------------------------------------------------------
 * <copyright file="GetChartStyle.cs" company="O-RID">
 *     Copyright (c)2010 O-RID Co.,Ltd.
 * </copyright>
 * <author>zhangjun</author>
 * <summary>
 *         设置图表数据的颜色
 *         
 *         作成日： 08/24/2010
 *                  09/03/2010  增加 图表X轴或Y轴上的数据样式
 *                  04/07/2011  增加 新颜色
 *                  05/18/2011  增加 新类别
 *</summary>
 *-----------------------------------------------------------------------
 */
namespace Orid.Management.Statistics.OperatorUnitMangement.Common.SytleSet
{
    using System;
    using System.Security.Cryptography;
    using System.Windows;
    using System.Windows.Controls.DataVisualization.Charting;
    using System.Windows.Media;

    public class GetChartStyle
    {

        #region 设置图表的颜色
        /// <summary>
        /// 设置图表的颜色
        /// </summary>
        /// <param name="strName"></param>
        /// <returns></returns>
        /// <value>
        /// 作成日：08/24/2010
        /// 05/18/2011 增加 英数字(浅色系)、日本語(深色系) 类别
        /// </value>
        public static Style GetChartColorStyle(string strName) 
        {
            Style retStyle = new System.Windows.Style();

            try
            {
                //默认为黑色
                Color setColor = Color.FromArgb(255, 0, 0, 0);

                //英数字 日本語
                switch (strName.Trim())
                {
                    // 线图用色
                    case "KYBER NOTE":
                    case "KYBER NOTE日本語":
                        //Crimson 深红
                        setColor = Color.FromArgb(255, 220, 20, 60);
                        break;
                    case "KYBER NOTE英数字":
                        //PaleVioletRed 苍白的紫罗兰红色
                        setColor = Color.FromArgb(255, 219, 112, 147);
                        break;

                    case "手書き":
                    case "手書き日本語":
                        //RoyalBlue 皇家蓝 (宝蓝)
                        setColor = Color.FromArgb(255, 65, 105, 225);
                        break;
                    case "手書き英数字":
                        //Navy 海军蓝 
                        setColor = Color.FromArgb(255, 0, 0, 128);
                        break;

                    case "名刺":
                    case "名刺日本語":
                        //DarkSlateGray 深石板灰
                        setColor = Color.FromArgb(255, 47, 79, 79);
                        break;
                    case "名刺英数字":
                        //LightSeaGreen 浅海洋绿
                        setColor = Color.FromArgb(255, 32, 178, 170);
                        break;

                    case "葉書":
                    case "葉書日本語":
                        //DarkOrchid 暗兰花紫
                        setColor = Color.FromArgb(255, 153, 50, 204);
                        break;
                    case "葉書英数字":
                        //
                        setColor = Color.FromArgb(255, 171, 130, 255);
                        break;

                    case "写真":
                    case "写真日本語":
                        //Yellow 金黄（纯黄）
                        setColor = Color.FromArgb(255, 241, 175, 0);
                        break;
                    case "写真英数字":
                        //DarkKhaki	深卡其布
                        setColor = Color.FromArgb(255, 189, 183, 107);
                        break;

                    case "活字":
                    case "活字日本語":
                        //DeepSkyBlue 深天蓝
                        setColor = Color.FromArgb(255, 0, 191, 255);
                        break;
                    case "活字英数字":
                        //CadetBlue 军校蓝 
                        setColor = Color.FromArgb(255, 95, 158, 160);
                        break;


                    // 2011-04-07 添加新颜色
                    case "Mini名刺":
                    case "Mini名刺日本語":
                        // Purple 紫色 
                        setColor = Color.FromArgb(255, 128, 0, 128);
                        break;
                    case "Mini名刺英数字":
                        // Violet 紫罗兰 
                        setColor = Color.FromArgb(255, 238, 130, 238);
                        break;

                    case "手書きメモ":
                    case "手書きメモ日本語":
                        // Olive 橄榄 
                        setColor = Color.FromArgb(255, 128, 128, 0);
                        break;
                        // Orange 橙色 
                    case "手書きメモ英数字":
                        setColor = Color.FromArgb(255, 255, 165, 0);
                        break;
                    

                    //---------------


                    // 柱图用色（稼动率）
                    case "出勤時間(H)":
                        // 浅灰
                        setColor = Color.FromArgb(255, 183, 183, 183);
                        break;
                    case "処理時間(H)":
                        // 白蓝
                        setColor = Color.FromArgb(255, 115, 136, 193);
                        break;
                    case "稼働率(処理時間)":
                        // Crimson 深红
                        setColor = Color.FromArgb(255, 220, 20, 60);
                        break;
                }

                retStyle.TargetType = typeof(System.Windows.Controls.Control);

                // 用这个Setter,没有点坐标
                // Setter controlLimitsetterTemplate = new Setter(System.Windows.Controls.Control.TemplateProperty, null);
                // 这个Setter,有点坐标
                Setter setterColor = new Setter(System.Windows.Controls.Control.BackgroundProperty, new SolidColorBrush(setColor));

                // retStyle.Setters.Add(controlLimitsetterTemplate);
                retStyle.Setters.Add(setterColor);
            }
            catch (Exception ex)
            {
                throw new Exception("数据样式设置有误! 其它信息：" + ex.Message.ToString());
            }
            return retStyle;
        }
        #endregion 设置图表的颜色

        #region 图表X轴或Y轴上的数据样式
        /// <summary>
        /// 取得图表X轴或Y轴上的数据样式
        /// </summary>
        /// <param name="axleName">x:x轴，y:y轴</param>
        /// <param name="chartFormat">设置小格式如 时间(H) 中的(H)</param>
        /// <returns></returns>
        public static Style GetChartAxleStyle(string axleName, string chartFormat)
        {
            //图表X轴或Y轴上的数据样式
            Style geteStyle = new System.Windows.Style();
            geteStyle.TargetType = typeof(System.Windows.Controls.Control);

            try
            {
                Setter setSytle = null;
                switch (axleName.ToUpper().Trim())
                {
                    case "X":
                        // 设置日期显示格式为 yyyy-M-d
                        setSytle = new Setter(AxisLabel.StringFormatProperty, "{0:yyyy-M-d}" + chartFormat);
                        break;
                    case "Y":
                        // 设置千分位分隔符
                        setSytle = new Setter(AxisLabel.StringFormatProperty, "{0:#,##0.##}" + chartFormat);
                        break;
                }
                geteStyle.Setters.Add(setSytle);
            }
            catch (Exception ex)
            {
                throw new Exception("数据样式设置有误! 其它信息：" + ex.Message.ToString());
            }
            return geteStyle;
        }
        #endregion 图表X轴或Y轴上的数据样式

    }
}
